package cn.zyq.ykb.system.pay.core.enums;

/**
 * @Description: 支付状态（0 待支付；1 下单成功-支付中；2 下单失败；3 回调成功-支付失败 4 回调成功-支付成功。）
 * @Author pengdoudou
 * @Date 2022/7/10 20:17
 */
public enum PayOrderStatusEnum {

    UNPAID("待支付", 0),
    PAYING("下单成功-支付中", 1),
    FAIL("下单失败", 2),
    NOTIFY_FAIL("回调成功-支付失败", 3),
    NOTIFY_SUCCESS("回调成功-支付成功", 4),
    // SYS_COIN("平台币", 4),
    // SCORE("积分", 5),

    ;
    private String key;
    private Integer value;

    private PayOrderStatusEnum(String key, Integer value) {
        this.key = key;
        this.value = value;
    }


    public static String getKeyByValue(Integer value) {
        for (PayOrderStatusEnum item : PayOrderStatusEnum.values()) {
            if (item.value.equals(value)) return item.key;
        }
        throw new RuntimeException( "无效的value值");
    }

    public static String getValueByKey(String key) {
        for (PayOrderStatusEnum item : PayOrderStatusEnum.values()) {
            if (item.key.equals(key)) return item.getValue().toString();
        }
        throw new RuntimeException("无效的key值");
    }


    public Integer getValue() {
        return value;
    }
}
